package com.knightboy.smartshoes.db;

/**
 * Created by 29288 on 2015/9/19.
 */

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 *建表
 */
public class DBHelper extends SQLiteOpenHelper {

    private static final String DB_NAME = "smartshoes";
    private static final int DB_VERSION = 1;
    private static DBHelper mInstance;

    public DBHelper(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
    }

    public DBHelper(Context context, int version) {
        super(context, DB_NAME, null, version);
    }

    public synchronized static DBHelper getInstance(Context context) {
        if (mInstance == null) {
            mInstance = new DBHelper(context);
        }
        return mInstance;
    };

    @Override
    public void onCreate(SQLiteDatabase db) {

        /**
         * 步数表
         */
        String sql_step = "Create table IF NOT EXISTS " + DBcolumns.TABLE_STEP
                + "(" + DBcolumns.STEP_ID + " integer primary key autoincrement,"
                + DBcolumns.STEP_NUM + " integer,"
                + DBcolumns.STEP_DAY + " text,"
                + DBcolumns.STEP_TIME + " text);";

        db.execSQL(sql_step);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
